Skip to main content
Version: 16.12.0

content_management

WordSearch

class WordSearch(Policy)

A content management policy for Word Search.

WordSearch(default="allow", config={ "textSearchConfig": { "@libVersion": "core2", "textList": [ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]}, ] } })

__init__

def __init__(default: str = "allow", config: dict = {})

add_textItem

def add_textItem(text: str,
replacementChar: str,
textSetting: str = "redact",
**kwargs)

Adds a textItem to the textSearchConfig textList subelements.

remove_textItem

def remove_textItem(text: str)

Removes a textItem from the textSearchConfig textList subelements.

Rebuild

class Rebuild(Policy)

A content management policy for Rebuild.

__init__

def __init__(default: str = "sanitise", config: dict = {})

Editor

class Editor(Policy)

A content management policy for Editor.

When used with the Editor library's set_content_management_policy, the engine's default policy settings are queried via GW2GetPolicySettings. If 'default' is specified, it is applied to all content switches. Any explicit overrides from 'config' are applied on top. If 'default' is None, the engine's own default values are used unmodified.

Arguments:

  • default Optional[str] - Default None. The value to set all content switches to (e.g. "sanitise", "allow", "disallow"). If None, the engine's own default values are used unmodified.
  • config dict - Explicit overrides for specific config elements and switches. e.g. {"pdfConfig": {"metadata": "allow"}}

__init__

def __init__(default: Optional[str] = None, config: dict = {})

ArchiveManager

class ArchiveManager(Policy)

A content management policy for ArchiveManager.

Arguments:

  • default str - The default action to be performed. (allow, disallow, sanitise)
  • default_archive_manager str - The default action to be performed for archiveConfig. (no_action, discard, process)
  • config dict - Additional configuration settings passed to the ConfigElement with the same name as the key.

Example:

ArchiveManager( default="allow", default_archive_manager="process", config={

  • "pdfConfig" - {"embeddedImages": "disallow"},
  • "wordConfig" - {"embeddedImages": "disallow"},
  • "archiveConfig" - {
  • "@recursionDepth" - "100",
  • "jpeg" - "discard" } } )

__init__

def __init__(default: str = "sanitise",
default_archive_manager: str = "process",
config: dict = {})

Policy

class Policy()

A Content Management Policy made up of a list of ConfigElement instances.

__init__

def __init__(config_elements: list = [],
default: Optional[str] = None,
default_config_elements: list = [],
config: dict = {},
**kwargs)

__str__

def __str__()

__getattr__

def __getattr__(name)

text

@property
def text()

String representation of XML.

encode

def encode(*args)

UTF-8 encoded string representation of XML.

get_config_element_names

def get_config_element_names()

Returns a sorted list of unique ConfigElement.name values from self.config_elements.

remove_switch

def remove_switch(config_element: Union[ConfigElement, str],
switch: Union[Switch, str])

Removes all Switch instances from config_element.switches that match arg "switch" where the ConfigElement instance in self.config_elements matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name to match.
  • switch Union[Switch, str] - A Switch instance or Switch.name to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.
  • glasswall.content_management.errors.switches.SwitchNotFound - The switch was not found.

add_switch

def add_switch(config_element: Union[ConfigElement, str],
switch: Switch,
replace: bool = True)

Adds a Switch to any ConfigElement in self.config_elements that matches arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or str to match ConfigElement.name.
  • switch Switch - A Switch instance.
  • replace bool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute as arg "switch" within a ConfigElement that matches arg "config_element".

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

remove_config_element

def remove_config_element(config_element: Union[ConfigElement, str])

Removes all ConfigElement instances from self.config_elements that match arg "config_element".

Arguments:

  • config_element Union[ConfigElement, str] - A ConfigElement instance or ConfigElement.name attribute to match.

Returns:

self

Raises:

  • glasswall.content_management.errors.config_elements.ConfigElementNotFound - The config_element was not found.

add_config_element

def add_config_element(config_element: ConfigElement, replace=True)

Adds a ConfigElement instance to self.config_elements.

Arguments:

  • config_element ConfigElement - A ConfigElement instance.
  • replace bool, optional - Default True. Deletes any pre-existing ConfigElement with the same .name attribute in self.config_elements.

Returns:

self

get_attributes

@staticmethod
def get_attributes(dictionary: dict)

Returns attributes from arg "dictionary". Attributes are key value pairs that have a key starting with "@". The "@" is excluded in the returned keys.

get_switches

@staticmethod
def get_switches(dictionary: dict)

Returns switches from arg "dictionary". Switches are key value pairs that do not have a key starting with "@".

from_string

@staticmethod
def from_string(string: str)

Create Policy object from string.

Arguments:

  • string str - A string representation of an xml content management policy, or a file path.

Returns:

  • new_policy glasswall.content_management.policies.Policy - A Policy object.

SwitchNotFound

class SwitchNotFound(ContentManagementPolicyError)

The Content Management Policy Switch could not be found.

RestrictedValue

class RestrictedValue(ContentManagementPolicyError)

The Content Management Policy Switch has an unexpected value.

ConfigElementNotFound

class ConfigElementNotFound(ContentManagementPolicyError)

The Content Management Policy ConfigElement could not be found.

ContentManagementPolicyError

class ContentManagementPolicyError(Exception)

Content Management Policy base error.

ConfigElement

class ConfigElement()

A Content Management Policy configuration element which has a name, and can have attributes, switches, and subelements.

__init__

def __init__(
name: str,
attributes: dict = {},
switches: list = [],
subelements: list = [],
default: Optional[str] = None,
default_switches: list = [],
config: dict = {},
switches_module: "glasswall.content_management.switches" = Switch)

__str__

def __str__()

__getattr__

def __getattr__(name)

__repr__

def __repr__()

Change string representation of object.

__lt__

def __lt__(other)

Used for sorting. Sort by "name" then "switches".

text

@property
def text()

String representation of XML.

get_switch_names

def get_switch_names()

Returns a sorted list of unique Switch.name values from self.switches.

remove_switch

def remove_switch(switch: Union[Switch, str])

Removes all Switch instances from self.switches that match arg "switch".

Arguments:

  • switch Union[Switch, str] - A Switch instance or str to match Switch.name.

Returns:

self

Raises:

  • glasswall.content_management.errors.switches.SwitchNotFound - The switch was not found.

add_switch

def add_switch(switch: Switch, replace: bool = True)

Adds a Switch instance to self.switches.

Arguments:

  • switch Switch - A Switch instance.
  • replace bool, optional - Default True. Deletes any pre-existing Switch with the same .name attribute in self.switches.

Returns:

self

archiveConfig

class archiveConfig(ConfigElement)

An archiveConfig ConfigElement.

Arguments:

  • default str - The default action: no_action, discard, or process.

    Key word arguments can be specified to change individual switch values: archiveConfig(default="no_action", jpeg="discard", pdf="process")

__init__

def __init__(default: str = "process", attributes: dict = {}, **kwargs)

textSearchConfig

class textSearchConfig(ConfigElement)

A textSearchConfig ConfigElement.

textSearchConfig( libVersion="core2", textList_subelements=[ {"name": "textItem", "switches": [ {"name": "text", "value": "generic"}, {"name": "textSetting", "@replacementChar": "*", "value": "redact"}, ]} ] )

__init__

def __init__(attributes: dict = {}, textList_subelements: list = [], **kwargs)

textList

class textList(ConfigElement)

A textList ConfigElement.

__init__

def __init__(subelements: list = [])

Switch

class Switch()

A Content Management Policy switch which has a name and a value, and can have attributes.

__init__

def __init__(name: str,
value: str,
attributes: Optional[dict] = None,
restrict_values: Optional[list] = None)

__str__

def __str__()

__repr__

def __repr__()

Change string representation of object.

__lt__

def __lt__(other)

Used for sorting. Sort by "name" then "value".

value

@property
def value()

value

@value.setter
def value(value)

text

@property
def text()

String representation of XML.

bmp

class bmp(Switch)

An ArchiveManager bmp switch.

__init__

def __init__(value: str)

doc

class doc(Switch)

An ArchiveManager doc switch.

__init__

def __init__(value: str)

docx

class docx(Switch)

An ArchiveManager docx switch.

__init__

def __init__(value: str)

elf

class elf(Switch)

An ArchiveManager elf switch.

__init__

def __init__(value: str)

emf

class emf(Switch)

An ArchiveManager emf switch.

__init__

def __init__(value: str)

gif

class gif(Switch)

An ArchiveManager gif switch.

__init__

def __init__(value: str)

jpeg

class jpeg(Switch)

An ArchiveManager jpeg switch.

__init__

def __init__(value: str)

mp3

class mp3(Switch)

An ArchiveManager mp3 switch.

__init__

def __init__(value: str)

mp4

class mp4(Switch)

An ArchiveManager mp4 switch.

__init__

def __init__(value: str)

mpg

class mpg(Switch)

An ArchiveManager mpg switch.

__init__

def __init__(value: str)

o

class o(Switch)

An ArchiveManager o switch.

__init__

def __init__(value: str)

pdf

class pdf(Switch)

An ArchiveManager pdf switch.

__init__

def __init__(value: str)

pe

class pe(Switch)

An ArchiveManager pe switch.

__init__

def __init__(value: str)

png

class png(Switch)

An ArchiveManager png switch.

__init__

def __init__(value: str)

ppt

class ppt(Switch)

An ArchiveManager ppt switch.

__init__

def __init__(value: str)

pptx

class pptx(Switch)

An ArchiveManager pptx switch.

__init__

def __init__(value: str)

tiff

class tiff(Switch)

An ArchiveManager tiff switch.

__init__

def __init__(value: str)

txt

class txt(Switch)

An ArchiveManager txt switch.

__init__

def __init__(value: str)

wav

class wav(Switch)

An ArchiveManager wav switch.

__init__

def __init__(value: str)

wmf

class wmf(Switch)

An ArchiveManager wmf switch.

__init__

def __init__(value: str)

xls

class xls(Switch)

An ArchiveManager xls switch.

__init__

def __init__(value: str)

xlsx

class xlsx(Switch)

An ArchiveManager xlsx switch.

__init__

def __init__(value: str)